-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MM-228] Add feature to update custom status and status of the user during meeting #359
Conversation
…move extra condition
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #359 +/- ##
==========================================
+ Coverage 20.94% 21.92% +0.98%
==========================================
Files 67 67
Lines 3442 3525 +83
==========================================
+ Hits 721 773 +52
- Misses 2628 2652 +24
- Partials 93 100 +7 ☔ View full report in Codecov by Sentry. |
I'm not too knowldeage with this plugin. @mickmister @fmartingr would you mind reviewing the PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems the same as I reviewed back in #355 👍
@AayushChaudhary0001 Can you please take a look at this PR when you have the chance? Thanks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work @raghavaggarwal2308 👍
I have some comments for discussion
calendar/engine/availability.go
Outdated
// Not setting custom status for events without attendees since those are unlikely to be meetings. | ||
if len(events[0].Attendees) < 1 { | ||
return "No attendee present, not setting custom status", isStatusChanged, nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if a meeting other than the first one has attendees?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This flow is updated now. We consider other meetings as well now.
calendar/engine/welcome_flow.go
Outdated
@@ -56,15 +56,18 @@ func (wf *WelcomeFlow) FlowDone(userID string) { | |||
|
|||
func (wf *WelcomeFlow) makeSteps() { | |||
steps := []flow.Step{ | |||
&flow.EmptyStep{ | |||
Title: "Update Status", | |||
Message: "You can update your status to \"Away\" or \"Do not disturb\" when you're in a meeting by typing `/mscalendar settings`.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This original wording makes me think it's telling me to run /mscalendar settings
while I'm in a meeting
Message: "You can update your status to \"Away\" or \"Do not disturb\" when you're in a meeting by typing `/mscalendar settings`.", | |
Message: "You can type `/mscalendar settings` to configure the plugin to update your status to \"Away\" or \"Do not disturb\" when you're in a meeting.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use ProviderConfig.Command
here instead of a fixed /mscalendar
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fmartingr I wonder if this is something we can configure the linter to catch?
e.Dependencies.Tracker = tracker.New( | ||
telemetry.NewTracker( | ||
p.telemetryClient, | ||
p.API.GetDiagnosticId(), | ||
p.API.GetServerVersion(), | ||
e.PluginID, | ||
e.PluginVersion, | ||
config.Provider.TelemetryShortName, | ||
telemetry.NewTrackerConfig(p.API.GetConfig()), | ||
telemetry.NewLogger(p.API), | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. So we haven't been tracking telemetry?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was no else condition present in the block in case e.Dependencies.Tracker
is nil. So added the else condition as well.
calendar/engine/availability_test.go
Outdated
"SetCustomStatus enabled but overlapping events": { | ||
settings: store.Settings{ | ||
SetCustomStatus: true, | ||
}, | ||
runAssertions: func(deps *Dependencies, client remote.Client) { | ||
c, papi, _, _, r := client.(*mock_remote.MockClient), deps.PluginAPI.(*mock_plugin_api.MockPluginAPI), deps.Poster.(*mock_bot.MockPoster), deps.Store.(*mock_store.MockStore), deps.Remote.(*mock_remote.MockRemote) | ||
moment := time.Now().UTC() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if I have a meeting in the next hour, and in the following hour after that I have two meetings that overlap. Will this make it so the first meeting (which in this case does not overlap) doesn't trigger a status update? Can we have a test made for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This case is updated now and we are handling overlapping events now.
From the discussion #228 (comment), it seems we should still change the user's status when there are overlapping meetings. We want to emulate real life as much as possible. If there is an event where I'm a (confirmed?) attendee, and there are other attendees, then the user's status should change |
Hi @raghavaggarwal2308 just checking in. Do you or another dev plan to continue work on this PR? |
@mickmister Yeah, we will pick this up asap. Apologies for the delay. |
@mickmister Fixed the review comment. Please re-review |
@@ -110,7 +110,7 @@ func (m *mscalendar) retrieveUsersToSync(userIndex store.UserIndex, syncJobSumma | |||
} | |||
|
|||
// If user does not have the proper features enabled, just go to the next one | |||
if !(user.Settings.UpdateStatusFromOptions != NotSetStatusOption || user.Settings.ReceiveReminders || user.Settings.SetCustomStatus) { | |||
if !(user.IsConfiguredForStatusUpdates() || user.IsConfiguredForCustomStatusUpdates() || user.Settings.ReceiveReminders) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I would expect these methods to be defined on user.Settings
, though I don't think it matters. This current way allows for less typing throughout the usages of the method
calendar/engine/availability.go
Outdated
for i := 1; i < len(events); i++ { | ||
if events[i-1].End.Time().UnixMicro() > events[i].Start.Time().UnixMicro() { | ||
return true | ||
if (events[idx].End.Time().UnixMicro() >= events[i].Start.Time().UnixMicro()) || (events[idx].End.Time().Sub(events[idx].Start.Time()) <= StatusSyncJobInterval && events[i].Start.Time().Sub(events[idx].End.Time()) <= StatusSyncJobInterval) { | ||
events[idx].End = events[i].End | ||
} else { | ||
idx++ | ||
events[idx] = events[i] | ||
} | ||
} | ||
|
||
return false | ||
return events[0 : idx+1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to put the body of this loop in its own function, and have it unit tested to show/document how it works
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mickmister Added a comment to it. I don't think we need to separately test the function as it is already covered by its parent function.
@@ -856,3 +1025,161 @@ func makeStatusSyncTestEnv(ctrl *gomock.Controller) (Env, remote.Client) { | |||
|
|||
return env, mockClient | |||
} | |||
|
|||
func TestGetMergedEvents(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the function is tested here 👍
Hi @AayushChaudhary0001, can you please review this when you have a chance? |
@mickmister Fixed the review fixes. Please re-review. |
@raghavaggarwal2308 I found two issue while testing this PR Issue 01: Wrong text is shown for the status change. Steps to reproduce:
Expected: Appropriate and accurate text should be shown. Issue 02: Custom status is not getting updated properly Steps to reproduce:
Expected: No delay should be there in updating the custom status of the second meeting |
@raghavaggarwal2308 I didn't realize this PR was needed for the custom status in Google Calendar plugin as well. We have a customer waiting on the GCal part. We'll need to test and merge this despite wanting to avoid big changes in MSCal, unless there is a better solution. |
@wiggin77 Sure, we will work on this PR on priority. Also, the issue in mscalendar plugin has been fixed now. We have also got the confirmation from the customer who was facing the issue earliar. |
…lendar into MM-188-fix
@AayushChaudhary0001 @arush-vashishtha The issues reported above are very rare edge cases. These are happening because our job to update status is running in every 5 mins. So, when two meetings are very close there might be some inconsistencies rarely. I think we should create a new issue for this particular case and spend time on this there. As this is out of scope for this PR. |
Approved this PR because the bug found are possibly out of the scope of this PR, these might be due to the time interval for updating the status by the job. Rest everything looks working fine in this PR(updating the custom status). |
Recreating this PR with the changes of #355 because of a lot of merge conflicts on that PR
Summary
Ticket Link
#228
Screenshots
What to test?
How to test?
/mscalendar settings
, select an option from theUpdate Status
setting, and check the updated status on the Mattermost./mscalendar settings
, set theSet Custom Status
setting to yes, and check the updated custom status on the Mattermost.